//
//  PKRadioHostessOtherWorks.m
//  PianKe
//
//  Created by lanou on 15/10/7.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "PKRadioHostessOtherWorks.h"
#import <UIButton+WebCache.h>
#import "PKWebViewController.h"
@interface PKRadioHostessOtherWorks()


@end
@implementation PKRadioHostessOtherWorks

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        _hostessLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 15, 40, 30)];
        _hostessLabel.text=@"主播";
        _hostessLabel.font=[UIFont systemFontOfSize:14];
        [self addSubview:_hostessLabel];
        _hostPeopleImg=[UIButton buttonWithType:UIButtonTypeCustom];
        _hostPeopleImg.frame=CGRectMake(55, 15, 30, 30);
        [_hostPeopleImg.imageView.layer setCornerRadius:15];
        [self addSubview:_hostPeopleImg];
        _hostNameLabel =[[UILabel alloc]initWithFrame:CGRectMake(90, 15, 100, 30)];
        _hostNameLabel.font=[UIFont systemFontOfSize:14];
        [self addSubview:_hostNameLabel];
        _textLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 55, 40, 30)];
        _textLabel.text=@"原文";
        _textLabel.font=[UIFont systemFontOfSize:14];
        [self addSubview:_textLabel];
        _textPeopleImg=[UIButton buttonWithType:UIButtonTypeCustom];
        _textPeopleImg.frame=CGRectMake(55, 55, 30, 30);
        [_textPeopleImg.imageView.layer setCornerRadius:15];
        [self addSubview:_textPeopleImg];
        _textNameLabel=[[UILabel  alloc]initWithFrame:CGRectMake(90, 55, 100, 30)];
        _textNameLabel.font=[UIFont systemFontOfSize:14];
        [self addSubview:_textNameLabel];
        _fromRadioLabel=[[UILabel alloc]initWithFrame:CGRectMake(10, 100, 60, 30)];
        _fromRadioLabel.font=[UIFont systemFontOfSize:14];
        _fromRadioLabel.text=@"来自电台";
        [self addSubview:_fromRadioLabel];
        _fromRadioNameLabel=[[UILabel alloc]initWithFrame:CGRectMake(80, 100, 100, 30)];
        _fromRadioNameLabel.font=[UIFont systemFontOfSize:14];
        [self addSubview:_fromRadioNameLabel];
        _authorOtherWork=[[UILabel alloc]initWithFrame:CGRectMake(10, 140, 100, 30)];
        _authorOtherWork.font=[UIFont systemFontOfSize:14];
        _authorOtherWork.text=@"作者的其他作品";
        [self addSubview:_authorOtherWork];
        _lineView=[[UILabel alloc]initWithFrame:CGRectMake(110, 155, SCREEN_WIDTH-110, 1)];
        _lineView.backgroundColor=[UIColor grayColor];
        [self addSubview:_lineView];
        UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc]init];
//        flowLayout.minimumLineSpacing=20;
//        flowLayout.minimumInteritemSpacing=20;
        self.hostessWorkCVC=[[PKRadioHostessWorksCollectionViewController alloc]initWithCollectionViewLayout:flowLayout];
        self.hostessWorkCVC.collectionView.frame=CGRectMake(15, 165, SCREEN_WIDTH-30, SCREEN_HEIGHT-230);
        [self addSubview:self.hostessWorkCVC.collectionView];
        self.hostessWorkCVC.collectionView.backgroundColor=[UIColor whiteColor];
        
        
        
    }
    return self;
}
-(void)setRadioDetailModel:(PKMainLessonModel *)radioDetailModel
{
    _radioDetailModel=radioDetailModel;
    [self.textPeopleImg sd_setImageWithURL:[NSURL URLWithString:radioDetailModel.playInfo.authorinfo.icon] forState:UIControlStateNormal];
    self.textNameLabel.text=radioDetailModel.playInfo.authorinfo.uname;
    [self.hostPeopleImg sd_setImageWithURL:[NSURL URLWithString:radioDetailModel.playInfo.userinfo.icon] forState:UIControlStateNormal];
    self.hostNameLabel.text=radioDetailModel.playInfo.userinfo.uname;
    [self.textPeopleImg addTarget:self action:@selector(skipToWebView:) forControlEvents:UIControlEventTouchUpInside];
    [self.hostPeopleImg addTarget:self action:@selector(skipToWebView:) forControlEvents:UIControlEventTouchUpInside];
    
}
-(void)skipToWebView:(UIButton *)button
{
       if (self.nextPageBlock!=nil) {
        self.nextPageBlock(self.radioDetailModel.playInfo.webview_url);
    }
    }

-(void)setRadionInfo:(PKRadioInfo *)radionInfo
{
    _radionInfo=radionInfo;
    self.fromRadioNameLabel.text=radionInfo.title;
}
@end
